package com.quxue.im.controller;

import com.quxue.im.req.apply.ApplyHandleReq;
import com.quxue.im.req.apply.ApplyReq;
import com.quxue.im.service.IChatApplyService;
import com.quxue.im.vo.AjaxResult;
import com.quxue.im.vo.apply.ApplyVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 好友申请表 前端控制器
 * </p>
 *
 * @author jinken
 * @since 2023-11-10
 */
@RestController
@RequestMapping("/apply")
public class ChatApplyController {

    @Resource
    private IChatApplyService applyService;

    /**
     * 好友申请
     * @param applyReq
     * @return
     */
    @RequestMapping("/add")
    public AjaxResult add(@RequestBody ApplyReq applyReq){
        applyService.applyFriend(applyReq);
        return AjaxResult.success();
    }

    /**
     * 好友申请列表
     * @return
     */
    @RequestMapping("/list")
    public AjaxResult list(){
        List<ApplyVo> pageRsult = applyService.selectList();
        return AjaxResult.success(pageRsult);
    }

    /**
     * 好友申请详情
     * @param applyId
     * @return
     */
    @RequestMapping("/info/{applyId}")
    public AjaxResult info(@PathVariable Long applyId){

        ApplyVo result = applyService.applyInfo(applyId);

        return AjaxResult.success(result);
    }


    @RequestMapping("/applyHandle")
    public AjaxResult applyHandle(@RequestBody ApplyHandleReq handleReq){
        applyService.applyHandle(handleReq);
        return AjaxResult.success();
    }

}
